package com.rul.mars.product.controller;

import com.rul.mars.common.api.CommonResult;
import com.rul.mars.mbg.domain.ProductCategoryNode;
import com.rul.mars.product.service.ProductCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商品分类服务接口
 *
 * @author RuL
 */
@Api(tags = "ProductCategoryController", description = "商品品牌服务")
@RestController
@RequestMapping("/product/category")
public class ProductCategoryController {

    @Autowired
    private ProductCategoryService categoryService;

    /**
     * 查询三级分类数据
     *
     * @return 以树形结构组织的三级分类数据
     */
    @ApiOperation("查询三级分类")
    @GetMapping("/categoryStructure")
    public CommonResult<List<ProductCategoryNode>> categoryStructure() {
        List<ProductCategoryNode> categoryNodes = categoryService.categoryStructure();
        return CommonResult.success(categoryNodes);
    }
}
